﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DataLibrary
{
    public class Ctbl_Tabs:IData<tbl_Tabs>
    {
        public Ctbl_Tabs(String myconnecString) : base(myconnecString) { }


        protected override int InsertOnSubmit(tbl_Tabs item, int t)
        {
            return connec.ExecuteNonQuery("ProTabs", CommandType.StoredProcedure, new SqlParameter("@flag", t),
                new SqlParameter("@"+tbl_Tabs.c_id,item.Id),new SqlParameter("@"+tbl_Tabs.c_TabText,item.TabText),
                new SqlParameter("@"+tbl_Tabs.c_TabUrl,item.TabUrl));
        }


        public override List<tbl_Tabs> GetAll(tbl_Tabs item)
        {
            throw new NotImplementedException();
        }

        public override tbl_Tabs GetItemById(object id)
        {
            return GetAll().SingleOrDefault(p => p.Id == Convert.ToInt32(id));
        }

        public override tbl_Tabs GetItem(IDataReader dr)
        {
            tbl_Tabs obj = new tbl_Tabs();
            obj.Id = Convert.ToInt32(dr[tbl_Tabs.c_id]);
            obj.TabText = dr[tbl_Tabs.c_TabText].ToString();
            obj.TabUrl = dr[tbl_Tabs.c_TabUrl].ToString();
            return obj;
        }

        public override List<tbl_Tabs> GetAll()
        {
            return GetAll("select * from " + tbl_Tabs.b_tbl_Tabs,CommandType.Text);
        }
    }
}
